<!--
 * @Author: Zhouxin 2201_75539691@noreply.gitcode.com
 * @Date: 2024-11-18 20:17:10
 * @LastEditors: Zhouxin 2201_75539691@noreply.gitcode.com
 * @LastEditTime: 2024-11-18 20:40:49
 * @FilePath: \2024.11.15-day05-隐式转换 控制流程c:\Users\zhou'xin\Desktop\Gitee仓库\qd-project-shizhibo\第二阶段：JavaScript\2024.11.18-day07-数组\demo2.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 二、抽茧剥丝
var arr = ['鸡腿',101,'3','奥利奥',9,false,'33a',1.333,'巧克力'];
求数组中所有类型为number的整数之和 -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = ['鸡腿',101,'3','奥利奥',9,false,'33a',1.333,'巧克力'];
        var sum = 0;
        for(var i = 0; i < arr.length; i++){
            if(typeof(arr[i])=="number" && arr[i] % 1 === 0){
                sum += arr[i];
            }
        }

        console.log(sum);
    </script>
</body>
</html>